//package com.yue.se.instrument;
//
//import jdk.internal.org.objectweb.asm.ClassReader;
//import jdk.internal.org.objectweb.asm.ClassWriter;
//import jdk.internal.org.objectweb.asm.Opcodes;
//import jdk.internal.org.objectweb.asm.tree.*;
//
//import java.lang.instrument.ClassFileTransformer;
//import java.lang.instrument.IllegalClassFormatException;
//import java.security.ProtectionDomain;
//
///**
// * 功能描述: TODO <br/>
// * 创建时间: 2016/8/8<br/>
// *
// * @author QiuYang
// */
//public class MyTransformer implements ClassFileTransformer {
//    @Override
//    public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException {
//        ClassReader classReader = new ClassReader(classfileBuffer);
//        ClassNode classNode = new ClassNode();
//        classReader.accept(classNode, 0);
//
//        for (Object obj : classNode.methods){
//            MethodNode methodNode = (MethodNode)obj;
//            if("<init>".endsWith(methodNode.name) || "<clinit>".equals(methodNode.name)){
//                continue;
//            }
//            InsnList insnList = methodNode.instructions;
//            InsnList insnList1 = new InsnList();
//
//            insnList1.add(new FieldInsnNode(Opcodes.GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;"));
//            insnList1.add(new LdcInsnNode("Enter method->" + classNode.name + "." + methodNode.name));
//            insnList1.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V"));
//
//            insnList.insert(insnList1);
//            methodNode.maxStack += 3;
//        }
//
//        ClassWriter classWriter = new ClassWriter(0);
//        classNode.accept(classWriter);
//
//        return classWriter.toByteArray();
//    }
//}
